//SPDX-FileCopyrightText: Copyright 2025-2025 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

package config_api_serv

import (
	"context"

	"gitcode.com/eteam/api-server/config"
	"gitcode.com/eteam/proto-gen-go.git/config_api"
)

type ConfigApiImpl struct {
	config_api.UnimplementedConfigApiServer
	config *config.ServerConfig
}

func NewConfigApiImpl(config *config.ServerConfig) *ConfigApiImpl {
	return &ConfigApiImpl{config: config}
}

func (apiImpl *ConfigApiImpl) GetServerConfig(ctx context.Context, req *config_api.GetServerConfigRequest) (*config_api.GetServerConfigResponse, error) {
	return &config_api.GetServerConfigResponse{
		Config: &config_api.ServerConfigInfo{
			CanUserRegister:   apiImpl.config.User.CanRegister,
			QuickUserRegister: apiImpl.config.User.QuickRegister,
		},
	}, nil
}
